<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
	<head>
		<base href="<%=basePath%>">
		<title>学院信息</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">    
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
			<link rel="stylesheet" type="text/css" href="styles.css">
		-->
		<link rel="stylesheet" type="text/css" href="<%=basePath %>scripts/static/h-ui/css/H-ui.min.css" />
		<link rel="stylesheet" type="text/css" href="<%=basePath %>scripts/static/h-ui.admin/css/H-ui.admin.css" />
		<link rel="stylesheet" type="text/css" href="<%=basePath %>scripts/lib/Hui-iconfont/1.0.7/iconfont.css" />
		<link rel="stylesheet" type="text/css" href="<%=basePath %>scripts/lib/icheck/icheck.css" />
		<link rel="stylesheet" type="text/css" href="<%=basePath %>scripts/static/h-ui.admin/skin/default/skin.css" id="skin" />
		<link rel="stylesheet" type="text/css" href="<%=basePath %>scripts/static/h-ui.admin/css/style.css" />
		<link rel="stylesheet" type="text/css" href="<%=basePath %>styles/page.css" />
		<script type="text/javascript" src="<%=basePath %>scripts/jquery-1.9.1.js"></script> 
		<script type="text/javascript" src="<%=basePath %>scripts/lib/layer/2.1/layer.js"></script>
		<script type="text/javascript" src="<%=basePath %>scripts/static/h-ui/js/H-ui.js"></script> 
		<script type="text/javascript" src="<%=basePath %>scripts/static/h-ui.admin/js/H-ui.admin.js"></script>
		<script type="text/javascript" src="<%=basePath %>scripts/jquery.dataTables.min.js"></script>
		<script type="text/javascript" src="<%=basePath %>scripts/dataTables.parse.js"></script>
		<script type="text/javascript">
			/*导出数据*/
			function exportStudent(){
				var key = "${collegeModel.keyword}";
				//layer.confirm('确认导出？',function(){
					if(key==""){
						window.location.href='<%=basePath%>college/collegeExport';
					}else{
						window.location.href='<%=basePath%>college/collegeExport?key='+key;
					}
				//});
			}
			/*导入数据*/
			function importStudent(){
				var index = layer.open({
					type:2,
					title:"添加学院",
					content:'<%=basePath%>exam/student-import.jsp'
				});
				layer.full(index);
			}
			/*添加学院*/
			function addCourceEmployee(){
				var index = layer.open({
					type:2,
					title:"添加学院",
					content:'<%=basePath%>exam/cource-employee-add.jsp'
				});
				layer.full(index);
			}
			
			/*单数据删除*/
			function deleteCourceEmployee(obj, teacherNo,sclassNo,courceNo){
				//alert(teacherNo+"--"+sclassNo+"---"+courceNo);
				var jsonUrl = "<%=basePath%>courceEmployee/deleteCourceEmployee";
				var inputData = {"id.teacherNo":teacherNo,"id.classNo":sclassNo,"id.courceNo":courceNo};
				layer.confirm('确认删除?',function(){
					$.ajax({
						url:jsonUrl,
						type:'post',
						dataType:'text',
						data:inputData,
						success:function(text){
							if(text == "success"){
								$(obj).parents("tr").remove();
								layer.msg('删除成功',{icon:1, time:500});
								window.location.reload();
							}
						},
						error:function(){
							layer.msg('删除异常',{icon:2,time:500});
						}
						
					});
				});
			}
			/*批量删除*/
			function deleteStudentList(obj){
				var s = "";
				$('input[name="array"]:checked').each(function(){
					//console.log($(this).attr("value"));
					s += $(this).attr("value")+",";
					
				});
				if(s==""){
					layer.msg('请选择数据');
				}else{
				layer.confirm('确认删除所选项?',function(){
					$.ajax({
						url:'<%=basePath%>student/deleteStudentList',
						dataType:'text',
						type:'post',
						data:{"array":s},
						success:function(text){
							layer.msg('删除成功');
							setTimeout(function(){
								window.location.reload();
							}, 1000);
						},
						error:function(){
							layer.msg('删除异常');
						}
					
					});
				});
				}
				
			}
			
			/*检查搜索*/
			function checkSearch(){
				var key = $("input[name='key']").val();
				key = key.replace(/(^\s+)|(\s+$)/g, "");
				if(key==""){
					layer.msg("关键字不能为空");
					$("input[name='key']").val("");
					return false;
				}else{
					return true;
				}
			}
		</script> 
	</head>
	<body>
		<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 
		首页 <span class="c-gray en">&gt;</span> 
		教师管理 <span class="c-gray en">&gt;</span>
		课程任免<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
		<i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<span class="l"><a href="javascript:;" onclick="deleteStudentList(this)" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> 
		<a class="btn btn-primary radius" data-title="添加学生" onclick="addCourceEmployee()" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 教师课程任免</a>
		<a class="btn btn-primary radius" data-title="数据导入" onclick="importStudent()" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 数据导入</a>
		<a class="btn btn-primary radius" data-title="数据导入" onclick="exportStudent()" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 数据导出</a>
		</span> 
		<span class="r">共有数据：<strong>${pageModel.totalrows }</strong> 条</span> 
	</div>
	<div class="mt-20">
		<table id="myTable" class="table table-border table-bordered table-bg table-hover table-sort">
			<thead>
				<tr class="text-c">
					<th width="25"><input type="checkbox" name="" value=""></th>
					<th width="25">序号</th>
					<th width="100">教师编号</th>
					<th width="120">教师姓名</th>
					<th width="25">任职课程</th>
					<th width="80">任职班级</th>
					<th width="80">操作</th>
				</tr>
			</thead>
			<c:choose>
			<c:when test="${pageModel.totalrows==0 }">
				<tbody>
					<tr class="text-c">
						<td colspan="8">没有数据</td>
					</tr>
				</tbody>
			</c:when>
			<c:otherwise>
				<tbody>
					<c:forEach items="${pageModel.list }" var="courceEmployee" varStatus="L">
						<tr class="text-c">
							<td><input type="checkbox" value="${courceEmployee.teacher.teacherNo }" id="collegeArray" name="array"></td>
							<td>${L.index+1 }</td>
							<td>${courceEmployee.teacher.teacherNo }</td>
							<td>${courceEmployee.teacher.teacherName }</td>
							<td>${courceEmployee.cource.courceName }</td>
							<td>${courceEmployee.sclass.className }</td>
							<td class="f-14 td-manage"> 
								<a style="text-decoration:none" class="ml-5" onClick="deleteCourceEmployee(this,'${courceEmployee.teacher.teacherNo}','${courceEmployee.sclass.classNo}','${courceEmployee.cource.courceNo}')" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
								
							</td>
						</tr>
					</c:forEach>
				</tbody>
			</c:otherwise>
			</c:choose>
			
		</table>
	</div>
</div>
	</body>
</html>